home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / c / ev_201.zip / TINPUT.HPP < prev    next >
C/C++ Source or Header  |  1993-07-03  |  4KB  |  115 lines

  1. #if !defined (TINPUT)                // Prevents multiple declarations errors
  2. #define TINPUT
  3.  
  4.  
  5. /*
  6.    Module        : TINPUT.HPP
  7.    Version       : 2.0
  8.    Revision date : July 3rd, 1993
  9.    Author(s)     : Remy Gendron
  10.  
  11.    Description   : Gets an input from keyboard or mouse, optionally using a
  12.                    filter and context sensitive help text.
  13. */
  14.  
  15.  
  16. // Headers ------------------------------------------------------------------
  17.  
  18. #include <dir.h>
  19. #include <stdio.h>
  20.  
  21.  
  22. // Macros -------------------------------------------------------------------
  23.  
  24. #include "stdmacro.h"                           // Standard macro definitions
  25. #define MOUSE_INT 0x33                            // Mouse's interrupt number
  26.  
  27.  
  28. // TypeDefs -----------------------------------------------------------------
  29.  
  30. #include "stdtype.h"                             // Standard type definitions
  31.  
  32. struct input_info                     // Holds keyboard and mouse input infos
  33. {
  34.    int  key_code ;                            // Ascii code of last char read
  35.    bool key_lshift ;            // TRUE if left shift key is pressed on input
  36.    bool key_rshift ;           // TRUE if right shift key is pressed on input
  37.    bool key_lctrl ;              // TRUE if left CTRL key is pressed on input
  38.    bool key_rctrl ;             // TRUE if right CTRL key is pressed on input
  39.    bool key_lalt ;                // TRUE if left ALT key is pressed on input
  40.    bool key_ralt ;               // TRUE if right ALT key is pressed on input
  41.    int  mouse_row ;        // Row position if mouse's left button was pressed
  42.    int  mouse_col ;        // Col position if mouse's left button was pressed
  43. } ;
  44.  
  45. struct hlp_idx                                 // To build index to help file
  46. {
  47.    int          hlpctx ;                               // Help context number
  48.    long int     filepos ;         // Position of context in help file (*.hlp)
  49.    word         hlplength ;                // Number of chars in this context
  50.    hlp_idx huge *next ;                         // Ptr to next struct in list
  51. } ;
  52.  
  53.  
  54. // Prototypes ---------------------------------------------------------------
  55.  
  56. class tinput
  57. {
  58.    bool          mouse_exists ;             // TRUE: A mouse driver was found
  59.    bool          mouse_visible ;                    // TRUE: Mouse is visible
  60.    bool          help_in_use ;  // TRUE: Help is in use (Don't use F1 again!)
  61.    int           last_hlpctx ; // Last input help context given to input::get
  62.    hlp_idx huge  *hifirst ;           // Ptr to first help_idx struct in list
  63.    char          pathtohelp[MAXPATH] ;          // Complete path to help file
  64.  
  65.  
  66. public:
  67.  
  68. far tinput () ;                                                // Constructor
  69.  
  70. far ~tinput () ;                                                // Destructor
  71.  
  72. void far tinput::mouse_init () ;                         // Initialises mouse
  73.  
  74. int far tinput::mouse_status () ;                   // Mouse's current status
  75.  
  76. void far tinput::mouse_show () ;                      // Shows mouse's cursor
  77.  
  78. void far tinput::mouse_hide () ;                      // Hides mouse's cursor
  79.  
  80. bool far tinput::mouse_lb_down () ;   // Tells if mouse's left button is down
  81.  
  82. void far tinput::mouse_pos                   // Gets current mouse's position
  83. (
  84.    int huge *row,                                   // To return row position
  85.    int huge *col                                    // To return col position
  86. ) ;
  87.  
  88. int far tinput::get                             // Gets a keyb or mouse input
  89. (
  90.    input_info huge *ii=NULL,                      // Ptr to input_info struct
  91.    int             filter=0,                  // Valid key code, or 0 for all
  92.    int             hlpctx=EV_NOHLPCTX,       // Context number while in {get}
  93.    bool            buffer=FALSE      // TRUE: Reads from keyb or mouse buffer
  94. ) ;
  95.  
  96.  
  97. private:
  98.  
  99. void far tinput::onlinehelp                           // Displays online help
  100. (
  101.    int hlpctx                                          // Help context number
  102. ) ;
  103.  
  104. } ;
  105.  
  106.  
  107. // --------------------------------------------------------------------------
  108.  
  109. extern tinput input ;                    // Reference to global tinput object
  110.  
  111.  
  112. // End Header File ----------------------------------------------------------
  113.  
  114. #endif
  115.